﻿/****************************************************************************
Copyright (c) 2014-2015 凌惊雪 微信:Lingjingxue 邮箱:lingjingxue@sina.com QQ:271487457

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/

using ServerBase.Protocol;
using ServerBase.Other;
using UtilPublic.ServerLoger;
using ServerBase.Service;
using UtilLib;
using System.Collections.Generic;
using System;
using ServerPublic.Manager;
using System.Collections;
using System.Text;
using UtilPublic.Security;
using System.Security.Cryptography;

namespace ServerGame.GameObject
{
    /// <summary>
    /// 玩家临时数据
    /// </summary>
    partial class Player
    {
        #region 账号

        //账号
        private string _Account = "";
        public string Account
        {
            get
            {
                if (_Account.IsNullOrEmpty())
                {
                    _Account = PubUserMgr.GetUserAccount(DaBasic.Uuid);
                }
                return _Account;
            }
        }

        #endregion

        //玩家登录时间
        public DateTime 在线时长统计时间 = new DateTime();

        //走马灯列表
        public List<CLS_NoticeRolling> ListNoticeRolling = new List<CLS_NoticeRolling>();

        #region 聊天

        public DateTime DtLastChat = UtilEnum.EpochDateTime;

        #endregion

        #region 私钥

        //私钥
        public long KeyPrivate = 0;
        public string KeyEncrypted = "";
        public void KeyEncryptedRefresh()
        {
            KeyPrivate = Util.Random.Next(10_0000);
            KeyEncrypted = KeyGetMD532((KeyPrivate * KeyPrivate * Puid).ToString(), Encoding.UTF8);
        }
        // 32位加密
        public static string KeyGetMD532(string s, Encoding _encoding)
        {
            MD5 md5 = new MD5CryptoServiceProvider();
            byte[] t = md5.ComputeHash(_encoding.GetBytes(s));
            StringBuilder sb = new StringBuilder(32);
            for (int i = 0; i < t.Length; i++)
            {
                sb.Append(t[i].ToString("x").PadLeft(2, '0'));
            }
            return sb.ToString();
        }

        #endregion

        #region 战斗



        #endregion

    }
}